// 包装 DatePicker 组件
import { extractModel, formatDate } from '@/utils/tools' 


export default {
    name: 'c-i-datePicker',
    functional:true,
    
    render (h, context){
        
        let {value, callback, conf}  = extractModel(context);

        let {

            size,
            options,
            type,
            format,
            placement,
            placeholder,
            splitPanels,
            multiple,
            showWeekNumbers,
            startDate,
            confirm,
            open,
            disabled,
            clearable,
            readonly,
            editable,
            transfer,

            _onChange,
            
        } = conf;

        function change(args){
            
            // 格式化时间
            let date = formatDate(args)
            
            // 自定义回调
            if(_onChange){
                _onChange(date)
            }
            
            callback(date)
        }
        
        return (

            <date-picker 
            onInput={change}
            
            value={value}
            options={options}
            type={type}
            format={format}
            placement={placement}
            placeholder={placeholder}
            split-panels={splitPanels}
            multiple={multiple}
            show-week-numbers={showWeekNumbers}
            startDate={startDate}
            confirm={confirm}
            open={open}
            disabled={disabled}
            clearable={clearable}
            readonly={readonly}
            editable={editable}
            transfer={transfer}
            size={size || 'small'}>
            </date-picker>
            
        )
    
        
    }

    
}